package com.elysia.visionmanagerspringboot.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.elysia.visionmanagerspringboot.domain.entity.VideoResolution;
import com.elysia.visionmanagerspringboot.mapper.VideoResolutionMapper;
import com.elysia.visionmanagerspringboot.service.IVideoResolutionService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@RequiredArgsConstructor
@Service
@Slf4j
public class IVideoResolutionServiceImpl extends ServiceImpl<VideoResolutionMapper, VideoResolution> implements IVideoResolutionService {
    @Override
    public List<VideoResolution> getByVideoId(Long videoId) {
        return lambdaQuery().eq(VideoResolution::getVideoId, videoId).list();
    }

    @Override
    public VideoResolution getByVideoIdAndResolution(Long videoId, String resolution) {
        return lambdaQuery().eq(VideoResolution::getVideoId, videoId).eq(VideoResolution::getResolution, resolution).one();
    }

    @Override
    public boolean deleteByVideoIdAndResolution(Long videoId, String resolution) {
        return lambdaUpdate().eq(VideoResolution::getVideoId, videoId).eq(VideoResolution::getResolution, resolution).remove();
    }
}
